<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String basePath = request.getScheme() + "://" + request.getServerName()
			+ ":" + request.getServerPort() + request.getContextPath();
%>
<jsp:include page="/WEB-INF/page/auth/_header.jsp"></jsp:include>
<body>
	<jsp:include page="/WEB-INF/page/auth/header.jsp"></jsp:include>
	<div id="middle">
		<jsp:include page="/WEB-INF/page/auth/menu.jsp"></jsp:include>
		<div id="right">
		    <div id="student_fruit_regtb">
		        <form id="student_fruit_regForm" class="m5">
		            学期：
		            <select class="form-control1" name="termId" id="termId"></select>
		            获奖级别：
		            <select class="form-control1" name="awardLevel" id="awardLevel"></select>
		            获奖等第：
		            <select class="form-control1" name="awardGrade" id="awardGrade"></select>
		            学生姓名：
		            <input class="form-control1" name="name" id="name">
					<input type="hidden" id="schoolId" name="schoolId" value=""/>
		            <a class="easyui-linkbutton l-btn l-btn-small" data-options="iconCls:'icon-search'" onclick="searchForm('student_fruit_reg')">查询</a>
		            <a class="easyui-linkbutton l-btn l-btn-small" data-options="iconCls:'icon-clear'" onclick="resetForm('student_fruit_reg')">重置</a><br/>
		        </form>
		    </div>
		    <table id="student_fruit_regdg">
		        <thead>
		            <tr>
		                <th data-options="field:'id',checkbox:true">ID</th>
		                <th data-options="field:'termId',title:'学期名称',editor:{
		                    type:'combobox',
		                    options:{
		                        editable:false,
		                        required:true,
		                        valueField:'id',
		                        textField:'termName',
		                        url:'<%=basePath %>/common/termList'
		                    }
		                },formatter:function(value,row,index){
		                    return row.termName;
		                }"></th>
		                <th data-options="field:'competitionName',title:'竞赛名称',editor:{
		                    type:'textbox',options:{required:true}},
		                formatter: function(value, row, index) {
		                    return '<span class=\'note\' title=\''+value+'\'>'+ value + '</span>';
		                }"></th>
		                <th data-options="field:'takeGroup',title:'参赛组别',editor:{type:'textbox'}"></th>
		                <th data-options="field:'takeSubProject',title:'参赛子项目',editor:{type:'textbox'}"></th>
		                <th data-options="field:'worksName',title:'作品名称',editor:{
		                    type:'textbox',options:{required:true}}"></th>
		                <th data-options="field:'grade',editor:{type:'combobox',options:{editable:false,required:true,onSelect:getClassByGrade,url:'<%=basePath %>/gradeCombo'}},formatter:function(value,row,index){
		                    return row.gradeName;
		                }">年级</th>
		                <th data-options="field:'clazz',editor:{type:'combobox',options:{editable:false,required:true,onSelect:getClassStudent}}">班别</th>
		                <th data-options="field:'studentId',formatter:function(value,row,index){return row.studentName},editor:{type:'combobox',options:{mode:'remote',required:true,valueField:'id',
		                        textField:'name'}}">学生姓名</th>
		                <th data-options="field:'awardLevel',title:'获奖级别',editor:{
		                    type:'combobox',
		                    options:{
		                        editable:false,
		                        required:true,
		                        url:'<%=basePath %>/common/getFruitParam/获奖级别',
		                        method:'GET'
		                    }}"></th>
		                <th data-options="field:'awardGrade',title:'获奖等第',editor:{
		                    type:'combobox',
		                    options:{
		                        editable:false,
		                        required:true,
		                        url:'<%=basePath %>/common/getFruitParam/获奖等第',
		                        method:'GET'
		                    }}"></th>
		                <th data-options="field:'awardDate',title:'获奖时间',editor:{
		                    type:'datebox',options:{required:true}}"></th>
		                <th data-options="field:'awardCompany',title:'授奖单位',editor:{type:'textbox',options:{required:true}}"></th>
		                <th data-options="field:'guideTeacher',title:'指导教师',editor:{type:'textbox'}"></th>
		                <th data-options="field:'remark',title:'备注',width:200,editor:{type:'textbox'},
		                formatter: function(value, row, index) {
		                    return '<span class=\'note\' title=\''+value+'\'>'+ value + '</span>';
		                }"></th>
		            </tr>
		        </thead>
		    </table>
		</div>
	</div>
	<jsp:include page="/WEB-INF/page/auth/_footer.jsp"/>
    <script type="text/javascript">
		var schoolId = $("#userSchoolId").val();
        $(function(){
            var url = basePath + "/sys/studentFruit/reg";
            var schoolId = $("#userSchoolId").val();
            initSchoolIdValue();
            initDatagridAdmin("student_fruit_reg",url,1,1,1,1,1);
            termList("student_fruit_reg");
            getFruitParam("student_fruit_reg","awardLevel","获奖级别");
	        getFruitParam("student_fruit_reg","awardGrade","获奖等第");
        });
        function getClassByGrade(record){
            var url="<%=basePath%>/common/getClazz?grade="+record.value;
            var ed=$('#student_fruit_regdg').datagrid('getEditor',{index:dgEditIndex['student_fruit_reg'],field:'clazz'}); 
            $(ed.target).combobox('setValue',"");
            $(ed.target).combobox('reload',url);
        }
        function getClassStudent(record){
            var ed=$('#student_fruit_regdg').datagrid('getEditor',{index:dgEditIndex['student_fruit_reg'],field:'grade'});
            var njh=$(ed.target).combobox('getValue');  
            var url="<%=basePath%>/common/getClassStudent?grade="+njh+"&clazz="+record.value+"&schoolId="+schoolId;
            var ed=$('#student_fruit_regdg').datagrid('getEditor',{index:dgEditIndex['student_fruit_reg'],field:'studentId'});   
            $(ed.target).combobox('setValue',"");
            $(ed.target).combobox('reload',url);
        }
    </script>
</body>
</html>